package com.qi.demo01.CAS;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author zjq
 * @date 2020/7/7 15:02
 */
public class CASDemo01 {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);

        System.out.println(atomicInteger.get());
        //initialValue:初始值
        //expect:期望值
        System.out.println(atomicInteger.compareAndSet(5, 2019) + "    current data" + atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5, 1024) + "    current data" + atomicInteger.get());
    }
}
